package com.aya.transaction.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class BlogSupportsTransactionService {
    @Resource
    BlogSimpleTransactionService blogSimpleTransactionService;

    @Transactional
    public int updateByIdSuccess(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdSupported(id2, content2);
        return i;
    }

    @Transactional
    public int updateByIdInnerFailure(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdSupportedException(id2, content2);
        return i;
    }
    @Transactional
    public int updateByIdCatchFailure(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        try {
            blogSimpleTransactionService.updateByIdSupportedException(id2, content2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return i;
    }



    public int updateByIdOuterSuccess(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdSupported(id2, content2);
        return i;
    }

    public int updateByIdOuterFailure(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdSupportedException(id2, content2);
        throw new RuntimeException("exception");
    }

}
